<?php
/**
 * 
 * The error controller manages error handling for Digitalus CMS
 *
 * @package    	Digitalus\Core
 * @category 	Controllers
 * @copyright  	Copyright (c) 2009,  Digitalus Media USA (http://digitalusmedia.net)
 * @license    	New BSD License, library/Dig/License.txt
 * @version 	2.0
 * 
 */
class ErrorController extends Zend_Controller_Action
{
    /**
     * the error action renders any errors which occur
     *
     * depending on the type of error this will either set:
     * 
     * * 404 response: this is sent if the controller or action is not found
     * * 500 response: this is sent if an application error occurs
     */
    public function errorAction ()
    {
        $errors = $this->_getParam('error_handler');
        switch ($errors->type) {
            case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER:
            case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ACTION:
                // 404 error -- controller or action not found
                $this->getResponse()->setHttpResponseCode(404);
                $this->view->message = 'Page not found';
                break;
            default:
                // application error 
                $this->getResponse()->setHttpResponseCode(500);
                $this->view->message = 'Application error';
                break;
        }
        $this->view->exception = $errors->exception;
        $this->view->request = $errors->request;
    }

    /**
     * the no auth action is run when the current user is not authorized to access the requested resource
     */
    public function noAuthAction()
    {
        
    }
}

